Skip to content

Adding DscExamplesPresent rule #95

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged

Conversation

KarolKaczmarek
Copy link
Contributor

Adding DscExamplesPresent rule (addressing Issue #84 )
DscExamplesPresent: Checks that DSC examples for given resource are present.
Rule expects directory Examples to be present:
For non-class based resources it should exist at the same folder level as DSCResources folder.
For class based resources it should be present at the same folder level as resource psm1 file.
Examples folder should contain sample configuration for given resource - file name should contain resource's name.

/// <returns>The results of the analysis</returns>
public IEnumerable<DiagnosticRecord> AnalyzeDSCResource(Ast ast, string fileName)
{
String fileNameOnly = fileName.Substring(fileName.LastIndexOf("\\", StringComparison.Ordinal) + 1);

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should use Path.GetFileName("fileName")

if (!examplesPresent)
{
yield return new DiagnosticRecord(string.Format(CultureInfo.CurrentCulture, Strings.DscExamplesPresentNoExamplesError, resourceName),
null, GetName(), DiagnosticSeverity.Information, fileName);

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We may want to use the dscClass.Extent here for the extent instead of null

@quoctruong
Copy link

Looks good to me.

quoctruong pushed a commit that referenced this pull request May 6, 2015
@quoctruong quoctruong merged commit 3f6ebbe into PowerShell:development May 6, 2015
@quoctruong
Copy link

Merged pull request

@KarolKaczmarek KarolKaczmarek deleted the DscExamplesPresentRule branch May 8, 2015 21:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants